<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ include file="/WEB-INF/jsps/tag.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>系统日志</title>
<%@ include file="/WEB-INF/jsps/common_css.jsp"%>
<%@ include file="/WEB-INF/jsps/common_js.jsp"%>

<script type="text/javascript">

$(function(){
	
	$('#log_list_id').datagrid({    
	    url:'${baseurl}log/list',
	    toolbar:"#log_toolbar_id",
	    fitColumns:false,
	    pageList:[14,28,42],
	    pageSize:14
	});

	//删除
	$("#log_delete_id").click(function(){
		var selected =  $("#log_list_id").datagrid("getSelected");
		if(selected == null){
			$.messager.alert('系统提示','请选中你要删除的记录.');  
		}else{
			$.post("${baseurl}log/delete", { "id":selected.id},
					   function(data){
					    	if(data.success){
					    		$('#log_list_id').datagrid("reload");
					    		$.messager.show({title:'系统提示',msg:data.content,timeout:5000,showType:'slide'});
					    	}else{
					    		$('#log_form_id').form("clear");
					    		$.messager.alert('警告',data.content); 
					    	}
					   }, "json");
		}
	});
	
	//清空所有
	$("#log_deleteall_id").click(function(){
		$.messager.confirm('确认','清空所有日志记录后不可恢复,您确认想要删除所有系统日志记录吗？',function(r){    
		    if (r){    
		    	$.post("${baseurl}log/deleteAll", {},
						   function(data){
						    	if(data.success){
						    		$('#log_list_id').datagrid("reload");
						    		$.messager.show({title:'系统提示',msg:data.content,timeout:5000,showType:'slide'});
						    	}else{
						    		$('#log_form_id').form("clear");
						    		$.messager.alert('警告',data.content); 
						    	}
						   }, "json");
		    }    
		});  
	});
	
	//高级查询
	$("#logList_query_button_id").click(function(){
		var logType = $("#logType").combobox("getValue");
		var username = $("#username").val();
		var startDate = $("#startDate").datebox("getValue");
		var endDate = $("#endDate").datebox("getValue");
		
		if(username!=null && username!=""){
			username = username.trim();
		}
		
		$('#log_list_id').datagrid("reload",{username:username,logType:logType,
														  startDate:startDate,endDate:endDate});
	});
	
	
});
	
</script>
</head>
<body>

	<!-- 搜索栏 -->
	<div style="height: 30px;width: 100%;border: 1px solid #BCB7B7;">
		<table>
			<tr>
				<th>操作人:</th>
				<td> <input id="username" name="username" class="easyui-textbox" type="text"  size="12" />  <td>
				<th>日志类型:</th>
				<td> 
					<select id="logType" class="easyui-combobox" name="logType" data-options="panelHeight:100,editable:false" style="width:100px;">
						<option value="-1">全部日志</option>      
					    <option value="BUSINESSLOG">操作日志</option>   
					    <option value="EXCEPTIONLOG">异常日志</option>
					</select>    
    			<td>
    			<th>开始时间:</th>
				<td> <input id="startDate" name="startDate" class= "easyui-datebox" type="text" data-options="editable:false" size="12"/>  <td>
				<th>结束时间:</th>
				<td> <input id="endDate"  name="endDate" class= "easyui-datebox" type="text" data-options="editable:false" size="12" />  <td>
    			<td>
    				<a id="logList_query_button_id" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-2012092109942'">过滤</a>  
    			</td>
			</tr>
		</table>
	</div>
	
	<!-- 数据表格 -->
	<table id="log_list_id" style="height:94%;"
		data-options="singleSelect:true,pagination:true,pagePosition:'bottom'">   
	    <thead>   
	        <tr>   
	            <th data-options="field:'id'">ID</th>   
	            <th data-options="field:'username'">用户名</th>
	            <th data-options="field:'operTime',formatter:function(value,row,index){
            			return showTime(value);
            		}">操作时间</th>
				<th data-options="field:'methods'">访问方法</th>
              	<th data-options="field:'requestIp'">访问IP</th>
              	<th data-options="field:'userId'">用户ID</th>
              	<th data-options="field:'logTyep',formatter:function(value,row,index){
            			if('EXCEPTIONLOG'==value){
            				return '<font color=red>异常日志</font>';
            			}else if('BUSINESSLOG'==value){
            				return '操作日志';
            			}
            		}">日志类型</th>
				<th data-options="field:'responseTime'">响应时间(毫秒)</th>
				<th data-options="field:'description'">描述</th>
              	<th data-options="field:'exceptionMsg'">异常消息</th>

	        </tr>   
	    </thead>   
	</table>
	
	<!-- 数据表格toolbar -->
	<div id="log_toolbar_id">
		<a id="log_delete_id" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true">删除一条</a>
		<a id="log_deleteall_id" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true">清空所有</a>
	</div>
	
</body>
</html>